package com.sunyard.inser.web.controller;

import java.io.InputStream;
import java.nio.charset.Charset;
import java.util.List;

import org.apache.dubbo.config.annotation.DubboReference;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.sunyard.inser.dto.DataTablesResult;
import com.sunyard.inser.dto.PageInfo;
import com.sunyard.inser.sys.entity.UserInfo;
import com.sunyard.inser.sys.service.UserService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

@Api(value = "/user", description = "关于用户的一些操做。")
@RestController
@RequestMapping("/user")
public class UserInfoController {
	
	private final static Logger logger = LoggerFactory.getLogger(UserInfoController.class);
	
	@DubboReference(check=false)
	private UserService userService;
	
//	@GetMapping("/list")
//	public String userList() {
//		System.out.println(Charset.defaultCharset());
//        InputStream in = SysController.class.getClassLoader().getResourceAsStream("userList.json") ;
//        byte[] buf = new byte[102400];
//        try {
//            in.read(buf);
//            String test = new String(buf, "UTF-8").trim();
//            System.out.println(test);
//            return test;
//        } catch (Exception e) {
//            // TODO Auto-generated catch block
//            e.printStackTrace();
//            return "500";
//        }	
//	}

	@GetMapping("/list")
	@ApiOperation(value = "通过 条件 查询 USER 列表信息", httpMethod = "GET", notes = "暂无")
	public DataTablesResult userList() {
        UserInfo userInfo = new UserInfo();
        PageInfo page = new PageInfo();
        DataTablesResult result = userService.getUserPage(page, userInfo);
        
        logger.info("result:{}", result);
        
		return result;		
	}
	
}
